package com.example.administrator.viewpaerdemo.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.PagerAdapter;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/8/27.
 */

public class ViewPagerAdapter extends FragmentStatePagerAdapter {
    private  ArrayList<Fragment> datas;
    private  String[] titles;

    public ViewPagerAdapter(FragmentManager fm, ArrayList<Fragment> fragments, String[] str) {
        super(fm);
        this.datas=fragments;
        this.titles=str;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

    @Override
    public Fragment getItem(int position) {
        return datas.get(position);
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    public void setData(ArrayList<Fragment> fragments, String[] str) {
        this.datas =fragments;
        this.titles=str;
    }

    @Override
    public int getItemPosition(Object object) {
        return PagerAdapter.POSITION_NONE;
    }
}
